-- 自动战斗实体（一般是怪物和助战）
local Entity = require("gameLogic.fightEntity.Entity")
local AutoEntity = class("AutoEntity", Entity)

function AutoEntity:ctor(manager, target)
    AutoEntity.super.ctor(self, manager, target)
end

function AutoEntity:start()
    AutoEntity.super.start(self)
end

function AutoEntity:_tick()
    if self._go then
        return
    end
    self._go = true
    local manager = self:getManager()
    local targets = manager:getEnemyEntitys(self:getStanding())
    if #targets == 0 then
        self:setDone(true)
        return
    end
    local index = math.random(1, #targets)
    self._skillList[1]:attack(index)
end

function AutoEntity:reset()
    AutoEntity.super.reset(self)
    self._go = false
end

function AutoEntity:onDestroy()
    AutoEntity.super.onDestroy(self)
end

return AutoEntity
